/**
 * Copyright (c) Tiny Technologies, Inc. All rights reserved.
 * Licensed under the LGPL or a commercial license.
 * For LGPL see License.txt in the project root for license information.
 * For commercial licenses see https://www.tiny.cloud/
 *
 * Version: 5.8.2 (2021-06-23)
 */
(function () {
  'use strict';
  tinymce.PluginManager.add('addSpace', function (editor) {
    var maxNum = editor.getParam('maxNum') || 20;
    // 注册一个工具栏按钮名称
    editor.ui.registry.addButton('addSpace', {
      text: '插入填空项',
      tooltip: '插入填空项',
      onAction: function () {
        if (editor.$(".q-space") && editor.$(".q-space").length < parseInt(maxNum)) {
          editor.insertContent('<span class="q-space" contenteditable="false">&nbsp;(&nbsp;)&nbsp;</span>');
        }
      }
    });
  });

}());
